package com.lonty.intelligence.service;

import com.lonty.intelligence.mapper.CommunityMapper;
import com.lonty.intelligence.model.Community;
import com.lonty.intelligence.util.UUIDUtil;
import com.lonty.intelligence.vo.CommunityVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 陈璇
 * @Date 2020/4/16 13:44
 * @Version 1.0
 **/
@Service
public class CommunityService {

    @Resource
    private CommunityMapper communityMapper;

    /**
     * 保存社区
     * @param communityVo
     * @return
     */
    public boolean saveCommunity(CommunityVo communityVo){
        Community community = new Community();
        BeanUtils.copyProperties(communityVo, community);
        community.setId(UUIDUtil.randomID());
        community.setIsDel(0);
        return communityMapper.saveCommunity(community) > 0;
    }

    /**
     * 获取所有社区
     * @return
     */
    public List<Community> getCommunityList(){
        return communityMapper.getCommunityList();
    }

}
